home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / MCC_TheBar / Developer / C / Examples / demo1.c next >
Encoding:
C/C++ Source or Header  |  2004-01-31  |  6.1 KB  |  159 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/TheBar_mcc.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9.  
  10. /***********************************************************************/
  11.  
  12. long __stack = 8192;
  13. struct Library *MUIMasterBase;
  14.  
  15. /***********************************************************************/
  16.  
  17. #ifndef MAKE_ID
  18. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  19. #endif
  20.  
  21. /***********************************************************************/
  22.  
  23. struct MUIS_TheBar_Button buttons[] =
  24. {
  25.     {0, 0, "_Pred", "Pread mail."},
  26.     {1, 1, "_Next", "Next mail."},
  27.     {2, 2, "_Move", "Move somewhere."},
  28.     {MUIV_TheBar_BarSpacer, 3},
  29.     {3, 4, "_Forw", "Forward somewhere."},
  30.     {4, 5, "F_ind", "Find something."},
  31.     {5, 6, "_Save", "Save mail."},
  32.     {MUIV_TheBar_End},
  33. };
  34.  
  35. /***********************************************************************/
  36.  
  37. char *appareances[] = {"Images and text","Images","Text",NULL};
  38. char *labelPoss[] = {"Bottom","Top","Right","Left",NULL};
  39.  
  40. int
  41. main(int argc,char **argv)
  42. {
  43.     int res;
  44.  
  45.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  46.     {
  47.         Object *app, *win, *sb, *appareance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;
  48.  
  49.         if (app = ApplicationObject,
  50.                 MUIA_Application_Title,         "TheBar Demo1",
  51.                 MUIA_Application_Version,       "$VER: TheBarDemo1 1.0 (24.6.2003)",
  52.                 MUIA_Application_Copyright,     "Copyright 2003 by Alfonso Ranieri",
  53.                 MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  54.                 MUIA_Application_Description,  "TheBar example",
  55.                 MUIA_Application_Base,         "THEBAREXAMPLE",
  56.  
  57.                 SubWindow, win = WindowObject,
  58.                     MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  59.                     MUIA_Window_Title,          "TheBar Demo1",
  60.                     WindowContents, VGroup,
  61.                         Child, sb = TheBarObject,
  62.                             GroupFrame,
  63.                             MUIA_Group_Horiz,       TRUE,
  64.                             MUIA_TheBar_EnableKeys, TRUE,
  65.                             MUIA_TheBar_Buttons,    buttons,
  66.                             MUIA_TheBar_PicsDrawer, "PROGDIR:Pics",
  67.                             MUIA_TheBar_Strip,      "Read.toolbar",
  68.                             MUIA_TheBar_SelStrip,   "Read_S.toolbar",
  69.                             MUIA_TheBar_DisStrip,   "Read_G.toolbar",
  70.                             MUIA_TheBar_StripCols,  11,
  71.                         End,
  72.                         Child, VGroup,
  73.                             GroupFrameT("Settings"),
  74.                             Child, HGroup,
  75.                                 Child, Label2("Appareance"),
  76.                                 Child, appareance = MUI_MakeObject(MUIO_Cycle,NULL,appareances),
  77.                                 Child, Label2("Label pos"),
  78.                                 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
  79.                             End,
  80.                             Child, HGroup,
  81.                                 Child, HSpace(0),
  82.                                 Child, Label1("Borderless"),
  83.                                 Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
  84.                                 Child, HSpace(0),
  85.                                 Child, Label1("Sunny"),
  86.                                 Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
  87.                                 Child, HSpace(0),
  88.                                 Child, Label1("Raised"),
  89.                                 Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
  90.                                 Child, HSpace(0),
  91.                                 Child, Label1("Scaled"),
  92.                                 Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
  93.                                 Child, HSpace(0),
  94.                             End,
  95.                         End,
  96.                         Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  97.                     End,
  98.                 End,
  99.             End)
  100.         {
  101.             ULONG sigs = 0, id;
  102.  
  103.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  104.             DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  105.  
  106.             set(win,MUIA_Window_Open,TRUE);
  107.  
  108.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  109.             {
  110.                 if (id==TAG_USER)
  111.                 {
  112.                     ULONG appareanceV, labelPosV, borderlessV, sunnyV, raisedV, scaledV;
  113.  
  114.                     get(appareance,MUIA_Cycle_Active,&appareanceV);
  115.                     get(labelPos,MUIA_Cycle_Active,&labelPosV);
  116.                     get(borderless,MUIA_Selected,&borderlessV);
  117.                     get(sunny,MUIA_Selected,&sunnyV);
  118.                     get(raised,MUIA_Selected,&raisedV);
  119.                     get(scaled,MUIA_Selected,&scaledV);
  120.  
  121.                     SetAttrs(sb,MUIA_TheBar_ViewMode,   appareanceV,
  122.                                 MUIA_TheBar_LabelPos,   labelPosV,
  123.                                 MUIA_TheBar_Borderless, borderlessV,
  124.                                 MUIA_TheBar_Sunny,      sunnyV,
  125.                                 MUIA_TheBar_Raised,     raisedV,
  126.                                 MUIA_TheBar_Scaled,     scaledV,
  127.                                 TAG_DONE);
  128.                 }
  129.  
  130.                 if (sigs)
  131.                 {
  132.                     sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  133.                     if (sigs & SIGBREAKF_CTRL_C) break;
  134.                 }
  135.             }
  136.  
  137.             MUI_DisposeObject(app);
  138.  
  139.             res = RETURN_OK;
  140.         }
  141.         else
  142.         {
  143.             printf("%s: can't create application\n",argv[0]);
  144.             res = RETURN_FAIL;
  145.         }
  146.  
  147.         CloseLibrary(MUIMasterBase);
  148.     }
  149.     else
  150.     {
  151.         printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  152.         res = RETURN_ERROR;
  153.     }
  154.  
  155.     return res;
  156. }
  157.  
  158. /***********************************************************************/
  159.